#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    vector<vector<int>> generateMatrix(int n)
    {
        // vector<vector<int>> vec;
        // vector<vector<int>> flag;
        // for (int i = 0; i < n; i++)
        // {
        //     vector<int> vec_row;
        //     for (int j = 0; j < n; j++)
        //     {
        //         vec_row.push_back(0);
        //     }
        //     vec.push_back(vec_row);
        //     flag.push_back(vec_row);
        // }
        // place(vec, 0, 0, n, 1, 1, flag);
        // return vec;
        vector<vector<int>> vec(n, vector<int>(n, 0));
        int i_start_pos = 0;
        int j_start_pos = 0;
        int loop = n / 2;
        int minus_length = 1;
        int num = 1;
        while (loop > 0)
        {
            loop--;
            int i = i_start_pos;
            int j = j_start_pos;
            for (; j < n - minus_length; j++)
            {
                vec[i][j] = num;
                num++;
            }
            for (; i < n - minus_length; i++)
            {
                vec[i][j] = num;
                num++;
            }
            for (; j > minus_length - 1; j--)
            {
                vec[i][j] = num;
                num++;
            }
            for (; i > minus_length - 1; i--)
            {
                vec[i][j] = num;
                num++;
            }
            i_start_pos++;
            j_start_pos++;
            minus_length++;
        }
        if (n % 2 != 0)
        {
            vec[n / 2][n / 2] = num;
        }
        return vec;
    }

    void place(vector<vector<int>> &vec, int row, int col, int n, int direction, int num, vector<vector<int>> &flag)
    {
        if (num > n * n)
        {
            return;
        }
        if (direction == 1)
        {
            // printf("%d %d %d\n", row, col, num);
            vec[row][col] = num;
            flag[row][col] = 1;
            col++;
            if (col == n || flag[row][col] == 1)
            {
                col--;
                row++;
                direction = 2;
            }
        }
        else if (direction == 2)
        {
            // printf("%d %d %d\n", row, col, num);
            vec[row][col] = num;
            flag[row][col] = 1;
            row++;
            if (row == n || flag[row][col] == 1)
            {
                row--;
                col--;
                direction = 3;
            }
        }
        else if (direction == 3)
        {
            // printf("%d %d %d\n", row, col, num);
            vec[row][col] = num;
            flag[row][col] = 1;
            col--;
            if (col == -1 || flag[row][col] == 1)
            {
                col++;
                row--;
                direction = 4;
            }
        }
        else if (direction == 4)
        {
            // printf("%d %d %d\n", row, col, num);
            vec[row][col] = num;
            flag[row][col] = 1;
            row--;
            if (row == -1 || flag[row][col] == 1)
            {
                row++;
                col++;
                direction = 1;
            }
        }
        place(vec, row, col, n, direction, num + 1, flag);
    }
};

int main()
{
    int n;
    cin >> n;
    Solution sol;
    vector<vector<int>> vec = sol.generateMatrix(n);
    for (auto vec1 : vec)
    {
        for (auto num : vec1)
        {
            cout << num << " ";
        }
        cout << endl;
    }
    return 0;
}